﻿using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

namespace Gmantis.Controls.Chart
{
    public class Symbol : PlotElement
    {
        // Fields
        protected Geometry geometry;
        protected Point symCenter = new Point();

        // Methods
        protected override bool IsCompatible(IRenderer rend)
        {
            if (!base.IsCompatible(rend))
            {
                return (rend is RadarRenderer);
            }
            return true;
        }

        protected override Size MeasureOverride(Size constraint)
        {
            this.UpdateGeometry(null, this.Size);
            return base.MeasureOverride(constraint);
        }

        protected override bool Render(RenderContext rc)
        {
            this.symCenter.X = rc.Current.X;
            this.symCenter.Y = rc.Current.Y;
            return true;
        }

        protected virtual void UpdateGeometry(PathGeometry pg, Size sz)
        {
        }

        // Properties
        internal override Rect LabelRect
        {
            get
            {
                this.UpdateGeometry(null, this.Size);
                return base.LabelRect;
            }
        }

        protected override Shape LegendShape
        {
            get
            {
                PlotElement element = (PlotElement)this.Clone();
                return element.Shape;
            }
        }

        public override Size Size
        {
            get
            {
                return base.Size;
            }
            set
            {
                if (base.Size != value)
                {
                    base.Size = value;
                    this.UpdateGeometry(null, this.Size);
                }
            }
        }
    }
}
